﻿// ServiceModel.Silverlight.Tests.Web.TestService.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license
// http://www.opensource.org/licenses/mit-license.html
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       TestService.cs
// Author:     HSS\gbanta
// Created:    08/12/2010
// Modified:   12/04/2010
// ----------------------------------------------------------------------------
using System;
using System.Linq;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Activation;
using HSS.ServiceModel;

namespace ServiceModel.Silverlight.Tests.Web
{
	[ServiceBehavior(Namespace = "https://secure.highspeed-solutions.net/testing", InstanceContextMode = InstanceContextMode.PerCall)]
	[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
	[BypassAuthentication]
	public class TestService : ITestService
	{
		public TestService()
		{
		}

		public void InvokeAsyncTest()
		{
			System.Diagnostics.Debug.WriteLine("InvokeAsyncTest");
		}

		public void InvokeActionAsyncTest()
		{
			System.Diagnostics.Debug.WriteLine("InvokeActionAsyncTest");
		}

		public string InvokeFuncAsyncTest()
		{
			System.Diagnostics.Debug.WriteLine("InvokeActionAsyncTest");
			return "Success";
		}

		public void InvokeActionWithErrorAsyncTest()
		{
			throw new Exception("Forced exception.");
		}

		public void InvokeTimeDelayed(int delaySeconds)
		{
			System.Threading.Thread.Sleep(delaySeconds * 1000);
		}

		public IEnumerable<Person> GetAllPeople()
		{
			return Person.GetPeople();
		}

		public bool UpdatePerson(Person person)
		{
			return null != person && !string.IsNullOrEmpty(person.FirstName);
		}

		public bool AddPeople(IEnumerable<Person> newPeople)
		{
			return null != newPeople && newPeople.Count() > 0;
		}

	}
}